package com.sg.qcgl.domain.ball_team.service.impl;

import com.sg.qcgl.domain.ball_team.model.BallTeam;
import com.sg.qcgl.domain.ball_team.service.BallTeamDomainService;
import com.sg.qcgl.domain.ball_team.gateway.BallTeamGateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ${author}
 * @date Thu Sep 04 12:28:40 CST 2025
 * @version 1.0
 */
@Service
public class BallTeamDomainServiceImpl implements BallTeamDomainService {

     @Autowired
     private BallTeamGateway ballTeamGateway;

     @Override
     public BallTeam create(BallTeam ballTeam) {
          // 判断
          if (ballTeam.judgeNewly()) {
               ballTeam.init();
               ballTeamGateway.create(ballTeam);
          }
          return ballTeamGateway.findById(ballTeam.getId());
     }

     @Override
     public BallTeam update(BallTeam ballTeamUpdateParams) {
          BallTeam ballTeamDb = ballTeamGateway.findById(ballTeamUpdateParams.getId());
          ballTeamDb.updateInfo(ballTeamUpdateParams);
          ballTeamGateway.updateById(ballTeamUpdateParams);
          return ballTeamGateway.findById(ballTeamUpdateParams.getId());
     }


}
